import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class Main extends JApplet {

	public Main() {
		map = new Map(8, 8);
		map.toggleObstacle(2, 1);
		map.toggleObstacle(2, 2);
		map.toggleObstacle(2, 3);
		map.toggleObstacle(1, 4);
		map.toggleObstacle(1, 5);
		map.toggleObstacle(3, 4);
		map.toggleObstacle(4, 1);
		map.toggleObstacle(5, 6);
		map.toggleObstacle(6, 5);
		map.toggleObstacle(6, 7);
		map.toggleObstacle(7, 4);
		
		map.calculatePath();
		repaint();
	}
	
	
    public void init() {
        //Initialize drawing colors
        setBackground(bg);
        setForeground(fg);
    }
    
    
    public void paint(Graphics g) {
    	Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setFont(font);
        map.render(g2);
    }

    
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//start		
        JFrame f = new JFrame("Main");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        });
        JApplet applet = new Main();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.pack();
        f.setSize(new Dimension((int)(7.5*sqrtThree*Tile.side), (int)(3.0*8.0/2.0*Tile.side)));
        f.setVisible(true);
	}
	
	private static double sqrtThree = 1.7320508075689;
	private Map map;

    final static Color bg = Color.white;
    final static Color fg = Color.black;
	private Font font = new Font("Dialog", Font.PLAIN, 12);
}
